﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CUILoader;
using FUI;
using LabelFUI;
using CheckBoxFUI;
using ComboBoxFUI;
using DateTimePickerFUI;
using ListBoxFUI;
using MainMenuFUI;
using MessageBoxFUI;
using NumericUpDownFUI;
using PictureBoxFUI;
using ProgressBarFUI;
using RadioButtonFUI;
using TextBoxFUI;
using Converter;

namespace FUINetCF
{
    public class CNetCFConverter : IConverter
    {
        public IFUI convertFromCUI(ICUI cuiControl)
        {
            IFUI fuiControl;
            fuiControl = new CCheckBoxFUI();

            switch (cuiControl.getName())
            {
                case "CheckBox" :
                    fuiControl = new CCheckBoxFUI();
                    break;
                case "ComboBox":
                    fuiControl = new CComboBoxFUI();
                    break;
                case "DateTimePicker":
                    fuiControl = new CDateTimePickerFUI();
                    break;
                case "Label":
                    fuiControl = new CLabelFUI();
                    break;
                case "ListBox":
                    fuiControl = new CListBoxFUI();
                    break;
                case "MainMenu":
                    fuiControl = new CMainMenuFUI();
                    break;
                case "MessageBox":
                    fuiControl = new CMessageBoxFUI();
                    break;
                case "NumericUpDown":
                    fuiControl = new CNumericUpDownFUI();
                    break;
                case "PictureBox":
                    fuiControl = new CPictureBoxFUI();
                    break;
                case "ProgressBar":
                    fuiControl = new CProgressBarFUI();
                    break;
                case "RadioButton":
                    fuiControl = new CRadioButtonFUI();
                    break;
                case "TextBox":
                    fuiControl = new CTextBoxFUI();
                    break;
                default:
                    
                    break;
            }

            //Chuyen gia tri tu CUI sang FUI
            foreach (CAttribute item in fuiControl.getAttributes())
            {
                item.StrValue = cuiControl.getAttributeFromName(item.StrName).StrValue;
            }

            return fuiControl;
        }

        public string NetCFGenerateDataType(CAttribute m_Att)
        {
            switch (m_Att.ValueType)
            {
                case eType.String:
                    return m_Att.StrValue;
                case eType.Int:
                    return m_Att.StrValue;
                case eType.Double:
                    return m_Att.StrValue;
                case eType.Boolean:
                    switch (m_Att.StrValue)
                    {
                        case "True" :
                            return "true";
                        case "False":
                            return "false";
                    }
                    break;
                case eType.XML:
                    return m_Att.StrValue;
                case eType.Char:
                    return m_Att.StrValue;
                case eType.eFontStyle:
                    switch (m_Att.StrValue)
                    {
                        case "Bold" :
                            return m_Att.StrValue;
                        case "Italic" :
                            return m_Att.StrValue;
                        case "Plain" :
                            return "Regular";
                        case "Underline" :
                            return m_Att.StrValue;
                    }
                    break;
                case eType.eFontSize:
                    switch (m_Att.StrValue)
                    {
                        case "Large" :
                            return "23";
                        case "Medium" :
                            return "15";
                        case "Small":
                            return "9";
                    }
                    break;
                case eType.ItemsCollection:
                    break;
                case eType.eForeColor:
                    switch (m_Att.StrValue)
                    {
                        case "White":
                            return "White";
                        case "Black":
                            return "Black";
                        case "Red":
                            return "Red";
                        case "Yellow":
                            return "Yellow";
                        case "Blue":
                            return "Blue";
                        case "Green":
                            return "Green";
                        default:
                            return m_Att.StrValue;
                    }
                case eType.eBackColor:
                    switch (m_Att.StrValue)
                    {
                        case "White":
                            return "White";
                        case "Black":
                            return "Black";
                        case "Red":
                            return "Red";
                        case "Yellow":
                            return "Yellow";
                        case "Blue":
                            return "Blue";
                        case "Green":
                            return "Green";
                        default:
                            return m_Att.StrValue;
                    }
                case eType.Decimal:
                    return m_Att.StrValue;
                default:
                    return "#NoValue#";
            }
            return "#NoValue#";
        }
    }
}
